﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class D04_PlayerPrefs : MonoBehaviour
{
    public int level;//等级
    private void Start()
    {
        level = PlayerPrefs.GetInt("level", 0);//读取,第二个参数时默认值
    }

    private void OnGUI()
    {
        GUILayout.Label("当前等级:" + level);
        if (GUILayout.Button("升级"))
        {
            level++;
            PlayerPrefs.SetInt("level", level);//保存
        }
    }
}